<template>
  <div @click="clickFull">
    <el-icon v-if="isShow">
      <full-screen/>
    </el-icon>

    <el-icon v-else>
      <full-screen/>
    </el-icon>
  </div>
</template>

<script>
export default {
  name: 'Screenfull',
}
</script>

<script setup>
import screenfull from 'screenfull' // 引入screenfull
import {onMounted, onUnmounted, ref} from 'vue'

defineProps({
  width: {
    type: Number,
    default: 22
  },
  height: {
    type: Number,
    default: 22
  },
  fill: {
    type: String,
    default: '#48576a'
  }
})

onMounted(() => {
  if (screenfull.isEnabled) {
    screenfull.on('change', changeFullShow)
  }
})

onUnmounted(() => {
  screenfull.off('change')
})

const clickFull = () => {
  if (screenfull.isEnabled) {
    screenfull.toggle()
  }
}

const isShow = ref(true)
const changeFullShow = () => {
  isShow.value = !screenfull.isFullscreen
}

</script>

<style scoped lang="scss">
.el-icon {
  font-size: 20px;
  color: white;
}

.el-icon:hover {
  color: #8bb425;
  font-size: 21px;
}
.screenfull-svg {
  width: 20px;
  height: 20px;
  cursor: pointer;
  vertical-align: middle;
  fill: rgba(0, 0, 0, 0.45);
}

</style>
